package de.g18.it0a.jlaser.gui.view;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public class ExtensionFileFilter extends FileFilter {

    private final String description;
    private final String extension;


    public ExtensionFileFilter(String aDescription, String aExtension) {
        description = aDescription;
        extension = aExtension.toLowerCase();
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public boolean accept(File file) {
        if (file.isDirectory()) {
            return true;
        }

        String path = file.getAbsolutePath().toLowerCase();
        return path.endsWith("." + extension);
    }
}
